package cn.cqsztech.leetcode;

/**
 * 11道解决思路
 */
public class N11 {
    public static int  solution(int[] args) {
        int left = 0;
        int right = args.length - 1;
        int height = 0;
        int squares = 0;
        //
        while (left < right) {
            if (args[left] < args[right]) {
                height = Math.min(args[left], args[right]);
                squares = Math.max(squares, height * (right-left));
                left ++;
            } else {
                height = Math.min(args[left], args[right]);
                squares = Math.max(squares, height * (right-left));
                right --;
            }
        }
        return squares;
    }

}
